{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<section class="panel">

    <header class="panel-heading">
        <h4>添加会员</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" method="post" onsubmit="return false" role="form">
            <div class="form-group">
                <label class="col-sm-2 control-label">手机号</label>

                <div class="col-sm-5">
                    <input type="text" value="" name="mobile" class="form-control"
                           placeholder="请输入手机号">
                </div>
                <div class="col-sm-3 help-block">
                    手机号码即登录账号，添加了不能被修改
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">合伙人类型</label>

                <div class="col-sm-8">
                    <label class="checkbox checkbox-custom pull-left">
                        <input type="radio" checked name="type" value="1" onchange="partnerType(1)">
                        市级合伙人
                    </label>
                    <label class="checkbox checkbox-custom pull-left">
                        <input type="radio"   name="type" value="2" onchange="partnerType(2)">
                        区/县级合伙人
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">省</label>

                <div class="col-sm-5">
                    <select name="province" class="form-control" id="province" onchange="changeCity()">

                        <option selected value="">请选择省份</option>

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">市</label>

                <div class="col-sm-5">
                    <select name="city" class="form-control" id="city" onchange="changeArea()">

                        <option selected value="">请选择市</option>

                    </select>
                </div>
            </div>
            <div class="form-group" id="area_box" >
                <label class="col-sm-2 control-label">区/县</label>

                <div class="col-sm-5">
                    <select name="area" class="form-control" id="area" >

                        <option selected value="">请选择区/县</option>

                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" onclick="main.ajaxPosts(this)" data-url="{:url('admin/user/insertPaetnerr')}"
                            class="btn btn-primary">提交
                    </button>
                </div>
            </div>

        </form>
    </div>
</section>
{/block}


{block name="footer"}
<script src="__PUBLIC__/admin/vendor/fuelux/checkbox.js"></script>
<script src="__PUBLIC__/admin/js/address.js"></script>
<script>
    var province = '';
    var city = '';
    var area = '';
    console.log(josns)
    for(var i in josns.province_list){

        province += `<option value="`+josns.province_list[i]+`" data_id="`+i+`">`+josns.province_list[i]+`</option>`;
    }

    $('#province').append(province);


    function changeCity(){
        city = '<option selected value="">请选择市</option>';
        var province_id = $('#province').find("option:checked").attr('data_id').substring(0,2);

        for(var i in josns.city_list){
            if(province_id == i.substring(0,2)){
                city += `<option value="`+josns.city_list[i]+`" data_id="`+i+`">`+josns.city_list[i]+`</option>`;
            }

        }
        $('#city').html(city);
    }
    function changeArea(){
        area = '<option selected value="">请选择市</option>';
        var city_id = $('#city').find("option:checked").attr('data_id').substring(0,4);

        for(var i in josns.county_list){
            if(city_id == i.substring(0,4)){
                area += `<option value="`+josns.county_list[i]+`" data_id="`+i+`">`+josns.county_list[i]+`</option>`;
            }

        }
        $('#area').html(area);
    }


    $('#area_box').hide();
    function partnerType(type){
        if(type == 1){
            $('#area_box').hide();
        }else{
            $('#area_box').show();
        }
    }

</script>
{/block}